unit LadderDlg;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls, 
  Buttons, ExtCtrls, LadderObj;

type
  TfrmLadderDlg = class(TForm)
    CancelBtn: TButton;
    GroupBox1: TGroupBox;
    GroupBox2: TGroupBox;
    Panel1: TPanel;
    cd_WithoutBasket: TCheckBox;
    cd_HideElements: TCheckBox;
    ed_B: TLabeledEdit;
    ed_Hp: TLabeledEdit;
    ed_h: TLabeledEdit;
    ed_u: TLabeledEdit;
    ed_A: TLabeledEdit;
    ed_R: TLabeledEdit;
    ed_Hk: TLabeledEdit;
    ed_d: TLabeledEdit;
    PaintBox1: TPaintBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure cd_WithoutBasketClick(Sender: TObject);
    procedure PaintBox1Paint(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    fparams: TLadder_Params;
  public
    constructor Create(aOwner: TComponent); override;
	destructor Destroy; override;
	procedure SetData (dataBuf: TLadder_Params);
	procedure GetData (var dataBuf: TLadder_Params);
  end;


implementation

uses Global;


{$R *.dfm}

constructor TfrmLadderDlg.Create (aOwner: TComponent);
begin
inherited Create(aOwner);
  fparams:= TLadder_Params.Create;
end;

destructor TfrmLadderDlg.Destroy;
begin
  fparams.Free;
inherited Destroy;
end;

procedure TfrmLadderDlg.SetData(dataBuf: TLadder_Params);
begin
	fparams.CopyFrom(dataBuf);
	
	cd_WithoutBasket.checked:= (not fparams.basket);
	cd_HideElements.checked:= fparams.hide_behind;
	

	ed_B.text:= FloatToStr(fparams.B);
	ed_Hp.text:= FloatToStr(fparams.Hp);
	ed_u.text:= FloatToStr(fparams.u);
	ed_h.Text:= FloatToStr(fparams.step);
	
	ed_A.Text:= FloatToStr(fparams.A);
	ed_R.Text:= FloatToStr(fparams.R);
	ed_Hk.Text:= FloatToStr(fparams.Hk);
	ed_d.Text:= FloatToStr(fparams.step1);
end;

procedure TfrmLadderDlg.GetData(var dataBuf: TLadder_Params);
begin
  fparams.Hp:= StrToFloat(ed_Hp.Text);
  fparams.B:= StrToFloat(ed_B.Text);
  fparams.step:= strToFloat(ed_h.Text);
  fparams.u:= strToFloat(ed_u.Text);
  
  fparams.A:= StrToFloat(ed_A.Text);
  fparams.R:= StrToFloat(ed_R.Text);
  fparams.step1:= StrToFloat(ed_d.Text);
  fparams.Hk:= StrToFloat(ed_Hk.Text);

  fparams.basket:= not cd_WithoutBasket.Checked;
  fparams.hide_behind:= cd_HideElements.Checked;
  
  dataBuf.CopyFrom(fparams);
end;


procedure TfrmLadderDlg.cd_WithoutBasketClick(Sender: TObject);
begin
  ed_A.Enabled:= not cd_WithoutBasket.checked;
  ed_R.Enabled:= not cd_WithoutBasket.checked;
  ed_Hk.Enabled:= not cd_WithoutBasket.checked;
  ed_d.Enabled:= not cd_WithoutBasket.checked;
  cd_HideElements.Enabled:= not cd_WithoutBasket.checked;
end;

procedure TfrmLadderDlg.PaintBox1Paint(Sender: TObject);
begin
  iKompas.ksDrawSlide(Panel1.Handle , fparams.GetSlideID );
  //ikompas.ksDrawSlideFromFile( Panel1.Handle, 'c:\Users\vit\Desktop\km\slide.rc' );
end;

procedure TfrmLadderDlg.BitBtn1Click(Sender: TObject);
begin
  fparams.drawType:= DT_LDR_FRONT;
end;

procedure TfrmLadderDlg.BitBtn2Click(Sender: TObject);
begin
  fparams.drawType:= DT_LDR_TOP;
end;

end.
